package com.chb.demo.dao;

import com.chb.demo.entity.Artist;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ArtistDao extends JpaRepository<Artist, Integer> {

    List<Artist> findArtistsBySidAndCidAndMasterpiece(Integer sid, Integer cid, String masterpiece);

    List<Artist> findArtistsByCidAndSidAndMasterpiece(Integer cid, Integer sid, String masterpiece);

    @Query(value = "select * from Artist a where if(?1 !='',a.cid=?1,1=1) and if(?2 !='',a.sid=?2,1=1)" +
            "and if(?3 !='',a.masterpiece=?3,1=1)  ",nativeQuery = true)
    List<Artist> searchArtist(Integer cid, Integer sid, String masterpiece);


}
